{{include file="public/header" /}}

{{include file="public/header_top_nav" /}}

{{include file="public/home_search" /}}

<!-- 订单确认页面顶部钩子-开始 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
    <div class="plugins-tag">
        <span>plugins_view_buy_top</span>
    </div>
{{/if}}
{{if !empty($plugins_view_buy_top_data) and is_array($plugins_view_buy_top_data)}}
    {{foreach $plugins_view_buy_top_data as $hook}}
        {{if is_string($hook) or is_int($hook)}}
            {{$hook|raw}}
        {{/if}}
    {{/foreach}}
{{/if}}
<!-- 订单确认页面顶部钩子-结束 -->

<!--收获地址页面 start -不需要body -->
<div class="container mTop20">
    <div class="row">
        <div class="col-lg-12 ">
            <div>
                {{if $common_site_type eq 0 or ($common_site_type eq 4 and (!isset($params['site_model']) or isset($params['site_model']) and $params.site_model eq 0))}}
                <table class="table" id="userAddresTab">
                    <thead>
                    <tr class="tableHead">
                        <th></th>
                        <th>Nombre</th>
                        <th>Estado</th>
                        <th>Dirección</th>
                        <th>Número de Celular</th>
                    </tr>
                    </thead>
                    <tbody>
                    {{if !empty($user_address_list)}}
                    {{foreach $user_address_list as $address}}
                    <tr>
                        <td class="pdLeft10">
                            {{if isset($address['is_default']) and $address['is_default'] eq 1}}
                            <input type="radio" name="addressRad" checked/>
                            {{else /}}
                            <input type="radio" name="addressRad"/>
                            {{/if}}
                        </td>
                        <td>
                            {{if isset($address['is_default']) and $address['is_default'] eq 1}}
                            <span class="am-badge am-badge-success-plain am-radius">Predeterminado</span>
                            {{/if}}
                            {{$address.name}}
                        </td>
                        <td>
                            {{$address.province_name}}{{$address.city_name}}{{$address.county_name}}
                        </td>
                        <td>
                            {{$address.address}}
                        </td>
                        <td>
                            {{$address.tel}}
                        </td>
                    </tr>
                    {{/foreach}}
                    {{else /}}
                    <tr>
                        <td colspan="5">
                            <div class="table-no">
                                <i class="am-icon-warning"></i>
                                <span>Sin dirección</span>
                                <button class="am-btn am-btn-secondary am-btn-xs am-margin-left-sm address-submit-save" type="button" data-url="{{:MyUrl('index/useraddress/saveinfo')}}" data-popup-title="Añadir dirección">Usar nueva dirección</button>
                            </div>
                        </td>
                    </tr>
                    {{/if}}
                    </tbody>
                </table>
                {{/if}}
            </div>
        </div>
    </div>
    <div class="row mTop50" id="goodsCarTab">
        <div class="col-lg-12">
            {{if !empty($buy_goods)}}
            <table class="table">
                <thead class="tableHead">
                <tr>
                    <th>Información Sobre Productos</th>
                    <th>Precio por Pieza</th>
                    <th>Cantidad</th>
                    <th>Total</th>
                </tr>
                </thead>
                <tbody>
                {{foreach $buy_goods as $v}}
                {{if !empty($v['goods_items'])}}
                {{foreach $v.goods_items as $goods}}
                <tr>
                    <td>
                        <!-- 分组商品详情基础顶部钩子-开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_buy_group_goods_base_top</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_buy_group_goods_base_top';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 分组商品详情基础顶部钩子-结束 -->
                        <div class="goods-detail">
                            <a href="{{$goods.goods_url}}" target="_blank">
                                <img src="{{$goods.images}}">
                            </a>
                            <div class="goods-base">
                                <a href="{{$goods.goods_url}}" target="_blank" class="goods-title">{{$goods.title}}</a>
                                {{if !empty($goods.spec)}}
                                <ul class="goods-attr">
                                    {{foreach $goods.spec as $spec}}
                                    <li>{{$spec.type}}：{{$spec.value}}</li>
                                    {{/foreach}}
                                </ul>
                                {{/if}}
                            </div>
                        </div>
                        <div class="wap-base am-show-sm-only">
                            {{if $goods['original_price'] gt 0}}
                            <span class="original-price">{{$currency_symbol}}{{$goods.original_price}}</span>
                            {{/if}}
                            <strong class="total-price-content">{{$currency_symbol}}{{$goods.price}}</strong>
                            <span class="wap-number">x{{$goods.stock}}</span>
                        </div>
                        <!-- 分组商品详情基础底部钩子-开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_buy_group_goods_base_bottom</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_buy_group_goods_base_bottom';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 分组商品详情基础底部钩子-结束 -->
                    </td>
                    <td>
                        {{if $goods['original_price'] gt 0}}
                        <p class="original-price">{{$currency_symbol}}{{$goods.original_price}}</p>
                        {{/if}}
                        <p class="line-price">{{$currency_symbol}}{{$goods.price}}</p>
                    </td>
                    <td>
                        <div class="pro-qty">
                            <label id="">{{$goods.stock}} {{$goods.inventory_unit}}</label>
                        </div>
                    </td>
                    <td>
                        <span>{{$currency_symbol}}</span><strong class="total-price-content">{{$goods.total_price}}</strong>
                    </td>
                </tr>
                {{/foreach}}
                {{else /}}
                <tr>
                    <td colspan="4">
                        <div class="table-no"><i class="am-icon-warning"></i> No hay mercancía</div>
                    </td>
                </tr>
                {{/if}}
                {{/foreach}}
                </tbody>
                <tfoot>
                <!-- 订单确认页面支付方式底部钩子-开始 -->
                {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                <div class="plugins-tag">
                    <span>plugins_view_buy_payment_bottom</span>
                </div>
                {{/if}}
                {{if !empty($plugins_view_buy_payment_bottom_data) and is_array($plugins_view_buy_payment_bottom_data)}}
                    {{foreach $plugins_view_buy_payment_bottom_data as $hook}}
                        {{if is_string($hook) or is_int($hook)}}
                            {{$hook|raw}}
                        {{/if}}
                    {{/foreach}}
                {{/if}}


                <!-- 订单确认页面支付方式底部钩子-结束 -->
                <tr>
                    <td colspan="5" class="pdLeft10">
                        <form class="am-form form-validation nav-buy" action="{{:MyUrl('index/buy/add')}}" method="post" class="nav-buy" request-type="ajax-fun" request-value="BuySubmitBack" data-site-type="{{$common_site_type}}" data-is-booking="{{$common_order_is_booking}}">
                            <input type="hidden" name="goods_id" value="{{if isset($params['goods_id'])}}{{$params.goods_id}}{{else /}}0{{/if}}"/>
                            <input type="hidden" name="buy_type" value="{{if isset($params['buy_type'])}}{{$params.buy_type}}{{else /}}goods{{/if}}"/>
                            <input type="hidden" name="stock" value="{{if isset($params['stock'])}}{{$params.stock}}{{else /}}1{{/if}}"/>
                            <input type="hidden" name="spec" value='{{if isset($params['spec'])}}{{$params.spec}}{{/if}}' />
                            <input type="hidden" name="ids" value="{{if isset($params['ids'])}}{{$params.ids}}{{/if}}"/>
                            <input type="hidden" name="address_id" value="{{if isset($base['address']) and isset($base['address']['id'])}}{{$base.address.id}}{{else /}}{{if isset($params['address_id'])}}{{$params.address_id}}{{else /}}-1{{/if}}{{/if}}"/>
                            <input type="hidden" name="payment_id" value="1"/><!--默认支付方式-->
                            <input type="hidden" name="user_note" value=""/>
                            <input type="hidden" name="site_model" value="{{if isset($params['site_model'])}}{{$params.site_model}}{{else /}}0{{/if}}"/>
                            <!-- 订单确认页面提交订单表单内部钩子-开始 -->
                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                            <div class="plugins-tag">
                                <span>plugins_view_buy_form_inside</span>
                            </div>
                            {{/if}}
                            {{if !empty($plugins_view_buy_form_inside_data) and is_array($plugins_view_buy_form_inside_data)}}
                            {{foreach $plugins_view_buy_form_inside_data as $hook}}
                            {{if is_string($hook) or is_int($hook)}}
                            {{$hook|raw}}
                            {{/if}}
                            {{/foreach}}
                            {{/if}}
                            <!-- 订单确认页面提交订单表单内部钩子-结束 -->
                            <div class="inlineFlex flexBaseLine buy-message" style="width: 100%;">
                                <div style="flex: auto;">
                                    <span class="fontSize16">Observaciones：</span>
                                    <input type="text" class="memo-input form-control inlineBlock" placeholder="Observaciones" style="width:80%"></input>
                                </div>
                                <div style="flex: auto;" class="text-right pRight20">
                                    <!--                                <span>共计<span>20</span>件商品</span>-->
                                    <span class="mLeft20">Total:</span>
                                    {{$currency_symbol}}<span class="carPriceColor">{{$base.actual_price}}</span>
                                    <button type="submit" class="btn btn-primary mLeft40 btn-go" data-am-loading="{loadingText:'处理中...'}" style="background:#337ab7;">Enviar Pedido</button>
                                </div>
                            </div>
                        </form>
                    </td>
                </tr>
                </tfoot>
            </table>
            {{else /}}
            <div class="table-no"><i class="am-icon-warning"></i> No hay mercancía</div>
            {{/if}}
        </div>
    </div>
</div>

<!-- 订单确认页面底部钩子-开始 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
    <div class="plugins-tag">
        <span>plugins_view_buy_bottom</span>
    </div>
{{/if}}
{{if !empty($plugins_view_buy_bottom_data) and is_array($plugins_view_buy_bottom_data)}}
    {{foreach $plugins_view_buy_bottom_data as $hook}}
    {{if is_string($hook) or is_int($hook)}}
    {{$hook|raw}}
    {{/if}}
    {{/foreach}}
{{/if}}
<!-- 订单确认页面底部钩子-结束 -->

<!-- 订单提交后提示弹层 -->
<!--<div class="am-modal am-modal-no-btn" tabindex="-1" id="buy-order-submit-modal">-->
<!--    <div class="am-modal-dialog">-->
<!--        <div class="am-modal-bd">-->
<!--            <div class="content am-vertical-align-middle am-padding-vertical-sm">-->
<!--                <p class="am-text-success">支付跳转中、请勿关闭页面</p>-->
<!--                <p class="am-text-warning am-margin-top-lg">支付失败或长时间未响应</p>-->
<!--                <p class="am-text-warning am-margin-xs">-->
<!--                    <span>进入</span>-->
<!--                    <a href="{{:MyUrl('index/order/index')}}" class="am-text-secondary">我的订单</a>-->
<!--                    <span>后可以重新发起支付</span>-->
<!--                </p>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->
<!--收获地址页面 end -不需要body -->

{{include file="public/footer_nav" /}}

{{include file="public/footer" /}}

<script type="text/javascript">
    // 提交订单回调
    function BuySubmitBack(e) {
        if (e.code == 0) {
            $('#buy-order-submit-modal').modal({
                closeViaDimmer: false,
                width: 280,
                height: 140
            });
            $.AMUI.progress.done();
            Prompt(e.msg, 'success');
            setTimeout(function () {
                window.location.href = e.data.jump_url;
            }, 1500);
        } else {
            $('form.form-validation').find('button[type="submit"]').button('reset');
            $.AMUI.progress.done();
            Prompt(e.msg);
        }
    }
</script>